<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class MasterRecord extends Model
{
    protected $fillable = ['ma_code','type','g_cod', 'c_code','s_code', 'indicators', 'record_date'];
    public static $grades = ['01'=>'初一','02'=>'初二','03'=>'初三','04'=>'高一','05'=>'高二','06'=>'高三'];
    public function getGradeAttribute()
    {
        return self::$grades[$this->attributes['g_code']];
    }

    public function class()
    {
        return $this->hasOne(Classes::class,'c_code','c_code');
    }
    public function master()
    {
        return $this->hasOne(Master::class,'ma_code','ma_code');
    }
    public function student()
    {
        return $this->hasOne(Student::class,'s_code','s_code');
    }
}
